import i18n from '@/lang'
// import parseTime, formatTime and set to filter
export { parseTime, formatTime } from '@/utils'

// 图标状态
export function tipStatusFmt(status) {
  const res = {
    0: 'x',
    1: '√'
  }
  return status in res ? res[status] : status
}

// 状态格式化
export function statusFmt(status) {
  var m = i18n.messages[i18n.locale]['status']
  m = m ? m : {}
  const res = {
    '-1': 'deleted' in m ? m['deleted'] : 'deleted',
    0: 'disabled' in m ? m['disabled'] : 'disabled',
    1: 'enabled' in m ? m['enabled'] : 'enabled'
  }
  return status in res ? res[status] : status
}

export function recommendedFmt(status) {
  var m = i18n.messages[i18n.locale]['recommended']
  m = m ? m : {}
  return status in m ? m[status] : status
}

// 判断是否格式化
export function whetherFmt(whether) {
  var b = i18n.messages[i18n.locale]['btn']
  b = b ? b : {}
  const res = {
    0: 'no' in b ? b['no'] : 'no',
    1: 'yes' in b ? b['yes'] : 'yes'
  }
  return whether in res ? res[whether] : whether
}

// 格林时间戳格式化
export function clientFmt(client) {
  return client.split(',')
}

// 广告类型格式化
export function bannerCategory(type) {
  var t = i18n.messages[i18n.locale]['table']
  t = t ? t : {}
  const res = {
    1: 'link' in t ? t['link'] : 'link',
    2: 'externalLink' in t ? t['externalLink'] : 'externalLink'
  }
  return type in res ? res[type] : type
}
